/**  
 * All rights Reserved, Designed By <a href="www.itttq.com" target="_blank">www.itttq.com</a>
 * @date:   2017-07-21 11:42:21
 * @Copyright: 2017 <a href="www.itttq.com" target="_blank">www.itttq.com</a> Inc. All rights reserved. 
 */
package com.itttq.gshop.generic.connector;

import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.itttq.gshop.domain.po.PayApplyPo;
import com.itttq.gshop.domain.to.ResultPageTo;
import com.itttq.gshop.domain.to.ResultTo;
import com.itttq.gshop.generic.util.Constants.PayMethod;
import com.itttq.gshop.generic.util.Constants.PayStatus;

@FeignClient(name= "${gshop.feign.server.pbpm}/payApply")
public interface IPayApplyConnector {
	/**
	 * 根据条件获取PayApplyPo对象，并返回查询的数据总数
	 * 
	 * @param payApply
	 * @Author 迷蝶
	 * @return ResultPageTo<PayApplyPo>
	 */
	@RequestMapping("list")
    public ResultPageTo<PayApplyPo> getPayApplys(@RequestBody PayApplyPo payApply);
	
	/**
	 * 根据ID获取PayApplyPo对象，并放入redis缓存
	 * 
	 * @param id	只能是数字
	 * @Author 迷蝶
	 * @return PayApplyPo
	 */
	@RequestMapping("/{id}")
	public PayApplyPo getPayApply(@PathVariable("id")int id);
	
	/**
	 * 根据订单ID生成支付请求，如果是线下支付，直接为支付成功并更新订单状态
	 * 
	 * @param orderId		订单ID
	 * @param payMethodId		支付方式ID。写死id=1为线下支付
	 * @Author 迷蝶
	 * @return ResultTo
	 */
	@RequestMapping("payApply/{orderId}/{payMethodId}")
	public ResultTo payApply(@PathVariable("orderId") int orderId, @PathVariable("payMethodId") int payMethodId);
	
	/**
	 * 根据ID删除PayApplyPo对象，并清除此ID的缓存。<br>
	 * 
	 * @param id	只能是数字
	 * @Author 迷蝶
	 * @return PayApplyPo
	 */
	@RequestMapping("/del/{id}")
	public Integer delPayApply(@PathVariable("id")int id);
	
	/**
	 * 处理支付结果，只校验支付金额是否和支付一致、支付方式，不做通知的签名校验。
	 * 
	 * @param orderId
	 * @param payApplyId
	 * @param payAmount
	 * @param pm
	 * @param ps
	 * @throws Exception
	 * @Author 迷蝶
	 * @return ResultTo
	 */
	@RequestMapping("payResult/{id}")
	public ResultTo payResult(@RequestParam("orderId") Integer orderId, @PathVariable("id") int payApplyId, 
			@RequestParam("payAmount") int payAmount, @RequestParam("pm") PayMethod pm, @RequestParam("ps") PayStatus ps);
}